<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
    <el-dialog :visible.sync="show" width="500px" :destroy-on-close="true" title="物流详情" v-loading="loading" :close-on-click-modal="false"
        append-to-body>
        <div class="currentItem-form" v-cloak>
            <el-form v-loading="loading" label-position="right" label-width="110px" size="small">

                <el-form-item label="快递名称" label-position="left">
                    <enumeration-selector cat="delivery_name" custom-style="width: 350px"
                        v-model="currentItem.delivery_company"></enumeration-selector>
                </el-form-item>

                <el-form-item label="快递单号" label-position="left">
                    <el-input v-model="currentItem.delivery_no" />
                </el-form-item>

                <div style="display: flex;justify-content: right;">
                    <el-button type="default" size="mini" @click="cancleHandle" icon="el-icon-close" :disabled="loading">取消</el-button>
                    <el-button type="primary" size="mini" @click="submitHandle" icon="el-icon-check" :disabled="loading">确定</el-button>
                </div>
            </el-form>
        </div>
    </el-dialog>
</template>

<script>
import { delivery, updateDelivery } from "@/api/score-order";
export default {
    components: {},
    data() {
        return {
            loading: false,
            currentItem: {},
            show: false,
        };
    },
    props: {

    },

    mounted: function () { },

    computed: {},

    methods: {
        cancleHandle: function () {
            this.show = false
        },
        openDialog: function (item) {
            this.currentItem = item;

            this.show = true;
        },
        submitHandle: function () {

            var data = this.currentItem;

            if (!data.delivery_company) {
                this.$message.error("请输入快递名称");
                return;
            }

            if (!data.delivery_no) {
                this.$message.error("请输入快递单号");
                return;
            }

            this.loading = true;
            if (data.status == 2) {
                updateDelivery(data).then((resp) => {
                    this.loading = false;
                    if (resp.status != 0) {
                        return;
                    }
                    this.$message.success("已保存！");
                    this.show = false;
                    this.$emit("change", this.currentItem);
                });
                return;
            }

            delivery(data).then((resp) => {
                this.loading = false;
                if (resp.status != 0) {
                    return;
                }
                this.$message.success("已保存！");
                this.show = false;
                this.$emit("change", this.currentItem);
            });

        },
    },
};
</script>

<style scoped></style>